import fetch from '@/utils/network/fetch'

// 获取列表内容    
const getstudyTask = (data, objc) => {
    data &&
        fetch('/api/learning', {
            ...objc,
            method: 'post',
            data
        })
}

// 删除某一条列表
const removeone = (lIds, objc) => {
    lIds &&
        fetch('/api/learning/deletion', {
            ...objc,
            method: 'post',
            data: { lIds }
        })
}

// 创建任务
const createTask = (data, objc) => {
    data &&
        fetch('/api/learning', {
            data,
            method: 'put',
            ...objc
        })
}

// 修改任务
const editTask = (data, objc) => {
    data && fetch(`/api/learning/${data.id}`, {
        loading: true,
        data,
        method: 'put',
        ...objc
    })
}

// 获取任务详情
const getTaskDetail = (data, objc) => {
    data && fetch(`/api/learning/${data.id}`, {
        loading: true,
        data,
        method: 'get',
        ...objc
    })
}

// 添加业务关系
const addTaskRelation = (data, objc) => {
    data && fetch(`/api/learning/${data.id}/business_relation`, {
        loading: true,
        data,
        method: 'put',
        ...objc
    })
}

// 根据ID 查询单个任务
const queryOneTask = (type, data, objc) => {
    data &&
        type &&
        fetch(`/api/learning/${type}`, {
            ...objc,
            method: 'post',
            data
        })
}

export default {

    getstudyTask,
    removeone,
    createTask,
    queryOneTask,
    editTask,
    getTaskDetail,
    addTaskRelation
}